package com.yeban.bams.entity;

import com.yeban.bams.exception.ATMException;
import com.yeban.bams.exception.BalanceNotEnoughException;

import java.io.Serializable;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/9
 *
 * 银行账户类
 */
public abstract class Account implements Serializable {

    /**
     * 成员属性
     */
    private Long id;            // 账户号码
    private String password;    // 账户密码
    private String name;        // 真实姓名
    private String personId;    // 身份证号码
    private String email;       // 电子邮箱
    private double balance;     // 账户余额
    private Integer type;       // 账户类型 - 添加字段
    private static final long serialVersionUID = 7370076290649548380L;

    public Account() {
    }

    public Account(Long id, String password, String name, String personId, String email, double balance) {
        this.id = id;
        this.password = password;
        this.name = name;
        this.personId = personId;
        this.email = email;
        this.balance = balance;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String toString() {
        return "Account{id = " + id + ", name = " + name + ", password = " + password + ", personId = " + personId + ", email = " + email + ", balance = " + balance + "}";
    }

    // 成员方法
    /**
     * 存款方法
     * @param money
     * @return
     */
    public final Account deposit(double money) {
        this.balance += money;
        return this;
    }

    /**
     * 取款方法
     * @param money
     * @return
     */
    public abstract Account withdraw(double money) throws BalanceNotEnoughException;
}

